package Proxy;

public class RealImage implements Image{

    private String fileName;

    public RealImage(String fileName){
        this.fileName = fileName;

        loadFromDisk(fileName);
        // 构造的时候就执行该操作. 对象构造成本高, 因此更需要设置代理控制访问: 直接 创建代理对象 来访问 realImage 对象. 而不是创建 realImage对象
    }

    public void loadFromDisk(String fileName){
        System.out.println("Load file: " + fileName + " form the disk ~ ");
    }

    @Override
    public void display() {
        System.out.println("RealImage implements Image to display file: " + fileName);
    }


}
